package com.lottery.ruok.lottrey.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.bean.QuickChoose;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by ASUS on 2017/11/13.
 */

public class HexiaoAdapterAdapter extends BaseAdapter {
    private ArrayList<QuickChoose> keys;
    private Context mContext;

    public HexiaoAdapterAdapter(ArrayList<QuickChoose> key, Context context) {
        keys = key;
        mContext = context;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view != null) {
            holder = (ViewHolder) view.getTag();
        } else {
            view = LayoutInflater.from(mContext).inflate(R.layout.liuhe_item5, null);

            holder = new ViewHolder(view);
            view.setTag(holder);
        }

        holder.number.setText(keys.get(i).getKey());
        if (keys.get(i).isChoose()) {
            holder.number.setBackgroundResource(R.drawable.bg_corners_100_6);
            holder.number.setTextColor(mContext.getResources().getColor(R.color.purples));
        } else {
            holder.number.setBackgroundResource(0);
            holder.number.setTextColor(Color.parseColor("#856c9c"));
        }

        return view;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public int getCount() {
        return keys.size();
    }

    static class ViewHolder {
        @BindView(R.id.name)
        TextView number;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
